package com.manolovn.trianglify.domain;

/**
 * Point entity
 */
public class Point {
    /**
     * x-axis point
     */
    public int x;

    /**
     * y-axis point
     */
    public int y;

    /**
     * Point parameterized constructor
     *
     * @param x-axis point
     * @param y-axis point
     * @return Point object
     */
    public Point(int x, int y) {
        this.x = x;
        this.y = y;
    }

    /**
     * this method is used to reduce given point from current point
     *
     * @param point need to be pass to reduce from current point
     * @return Point object
     */
    public Point sub(Point point) {
        return new Point(this.x - point.x, this.y - point.y);
    }

    /**
     * this method is used to add given point from current point
     *
     * @param point need to be pass to add from current point
     * @return Point object
     */
    public Point add(Point point) {
        return new Point(this.x + point.x, this.y + point.y);
    }

    /**
     * this method is used to multiply given point from current point
     *
     * @param scalar need to be pass to multiply from current point
     * @return Point object
     */
    public Point mult(int scalar) {
        return new Point(this.x * scalar, this.y * scalar);
    }

    /**
     * this method is used to square root of current point
     * @return double type result
     */
    public double mag() {
        return Math.sqrt(this.x * this.x + this.y * this.y);
    }

    /**
     * this method is used to multiply given point from current point
     * @return double type resultt
     */
    public double dot(Point point) {
        return this.x * point.x + this.y * point.y;
    }

    /**
     * this method is used to multiply given point from current point crossly
     * @return double type resultt
     */
    public double cross(Point point) {
        return this.y * point.x - this.x * point.y;
    }
}
